{extend name="../../../application/admin/view/Base/base"/}

{block name="body"}
    <div class="page-bar">
        <ul class="page-breadcrumb">
            <li>
                <a href="{:url('admin/Index/index')}">首页  </a>
                <i class="fa fa-circle"></i>
            </li>
            <li>
                <span>{$title}</span>
            </li>
        </ul>
        <div class="page-toolbar">
            {include file="../../../application/admin/view/Base/_addTo"/}
        </div>
    </div>

    <div class="main-title">
        <h2>{$title}            {if condition="$suggest"}（{$suggest}）{/if}</h2>
    </div>

    <div class="with-padding">
        <div class="tab-wrap tabbable-custom" style="margin-bottom: 5px">
            <ul class="nav nav-tabs group_nav">
                {volist name="group" id="vGroup"}
                    <li class="{if condition="$i eq 1"}active{/if}"><a href="javascript:">{$key}</a></li>
                {/volist}
            </ul>
            <div class="tab-content">
                <form action="{$savePostUrl}" method="post" class="form-horizontal">
                    {php}if($group){{/php}
                    <!--看板-->
                    {volist name="group" id="vGroup"}
                        <div class="group_list" style="{if condition='$i neq 1'}display: none;{/if}">
                            {volist name="keyList" id="field"}
                                {php}if(in_array($field['name'],$vGroup)||(is_array($field['name'])&&in_array(implode('|', $field['name']),$vGroup))){{/php}
                                {include file="../../../application/admin/view/Builder/_key"/}
                                {php}}{/php}
                            {/volist}
                        </div>
                    {/volist}

                    {php}}else{{/php}
                    {volist name="keyList" id="field"}
                        {include file="../../../application/admin/view/Builder/_key"/}
                    {/volist}
                    {php}}{/php}
                    <br/>

                    <div class="form-item">
                        {volist name="buttonList" id="button"}
                            <button {$button.attr}>{$button.title}</button>  &nbsp;
                        {/volist}
                    </div>
                </form>
            </div>
        </div>
    </div>

{/block}

{block name="script"}
{present name="$has_nestable"}
    {if condition="$has_nestable"}
        {load href="/admin/static/bootstrap/plugins/jquery-nestable/jquery.nestable.css" /}
        {load href="/admin/static/bootstrap/plugins/jquery-nestable/jquery.nestable.js" /}
        {load href="/admin/static/bootstrap/js/ui-nestable.min.js" /}
        <script>
            $('.nestables').find('.dd').nestable({
                maxDepth:1
            });
            $('.nestable_list_one').on('change',function(){
                var obj=$(this).parents('.nestables');
                var nestable=new Array();
                obj.find('.portlet').each(function(index,element){
                    if ($(element).data('id')) {
                        nestable[index] =  new Object();
                        nestable[index]['data-id'] =  $(element).data('id');
                        nestable[index]['title'] =  $(element).data('title');
                        nestable[index]['items'] =  $(element).find('.dd').nestable('serialize');
                        nestable[index]['items'].forEach(function(li){
                            li['data-id']=li['id'];
                        });
                    }
                });
                var nestable_str=JSON.stringify(nestable);
                var flag=obj.data('name');
                $('[name="'+flag+'"]').val(nestable_str);
            });
        </script>
    {/if}
{/present}

    <script type="text/javascript">
        $(function () {
            $('.group_nav li a').click(function () {
                $('.group_list').hide();
                $('.group_list').eq($(".group_nav li a").index(this)).show();
                $('.group_nav li').removeClass('active');
                $(this).parent().addClass('active');
            })
        })
        Think.setValue("type", {$info.type|default=0});
        Think.setValue("group", {$info.group|default=0});
        //导航高亮
        highlight_subnav('{:url('Config / index')}');
    </script>
    {load href="/js/ext/magnific/magnific-popup.css" /}
    {load href="/js/ext/magnific/jquery.magnific-popup.min.js" /}

    {load href="/js/ext/webuploader/js/webuploader.js" /}
    {load href="/js/ext/webuploader/css/webuploader.css" /}

    <script>
        $(document).ready(function () {
            $('.popup-gallery').each(function () { // the containers for all your galleries
                $(this).magnificPopup({
                    delegate: 'a',
                    type: 'image',
                    tLoading: '{:lang("_LOADING_")}#%curr%...',
                    mainClass: 'mfp-img-mobile',
                    gallery: {
                        enabled: true,
                        navigateByImgClick: true,
                        preload: [0, 1] // Will preload 0 - before current, and 1 after the current image

                    },
                    image: {
                        tError: '<a href="%url%">{:lang("_PICTURE_")}#%curr%</a>{:lang("_COULD_NOT_BE_LOADED_")}',
                        titleSrc: function (item) {
                            /*           return item.el.attr('title') + '<small>by Marsel Van Oosten</small>';*/
                            return '';
                        },
                        verticalFit: true
                    }
                });
            });

        });
    </script>
{/block}
